const json = require('./pcas-code.json')

exports.getAddress = () => {
  // 从 options 中随机生成
  const province = json[Math.floor(Math.random() * json.length)]
  const city = province.children[Math.floor(Math.random() * province.children.length)]
  const district = city.children[Math.floor(Math.random() * city.children.length)]
  const street = district.children[Math.floor(Math.random() * district.children.length)]
  const obj = {
    province: province.name,
    city: city.name,
    district: district.name,
    street: street.name
  }

  const result = [
    obj.province,
    obj.city ?? '',
    obj.district ?? '',
    obj.street ?? '',
  ]

  return result.join('') + ' ****** ***'
}

console.log(exports.getAddress())
